<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .bar{
            
            width: 0;
            height:20px;
            border:1px red solid;
            transition: all 1s linear;
        }
    </style>
</head>
<body>
    <input id="username" type="text" autocomplete="off">
    <div class="bar">

    </div>
    <script>
        let username = document.getElementById("username");
        let bar = document.querySelector(".bar");
        username.oninput = function(){
            let weight = 0;
            console.log(username.value.search(/[a-z]/));
            if(username.value.length >= 6 && username.value.length <= 10){
                weight++;
                console.log("length");
            }
            if(username.value.search(/[a-z]/) >= 0){
                weight++;
                console.log("a-z",username.value);
            }
            if(username.value.search(/[A-Z]/) >= 0){
                
                weight++;
                console.log("A-Z");
            }
            if(username.value.search(/\d/) >= 0){
                weight++;
                console.log("d");
            }
            console.log("weight：",weight);

            if(weight < 2){
                bar.style.width = "100px";
                bar.style.backgroundColor = "orange";
            }else if(weight < 4){
                bar.style.width = "200px";
                bar.style.backgroundColor = "green";
            }else{
                
            }

        }
    </script>
</body>
</html>